unit U_ArgeNumuneFormuListe;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, cxStyles, cxCustomData, cxGraphics, cxFilter, cxData,
  cxDataStorage, cxEdit, DB, cxDBData, cxCurrencyEdit, cxButtonEdit,
  StdCtrls, wwdbdatetimepicker, ExtCtrls, Buttons, cxGridLevel,
  cxGridCustomTableView, cxGridTableView, cxGridDBTableView, cxClasses,
  cxControls, cxGridCustomView, cxGrid, ActnList, ADODB, Menus, siComp,
  siLngLnk;

type
  TfmArgeNumuneFormuListe = class(TForm)
    cxgrid1: TcxGrid;
    cxgrid1DBTableView1: TcxGridDBTableView;
    cxgrid1Level1: TcxGridLevel;
    pnlButton: TPanel;
    bKapat: TBitBtn;
    bListele: TBitBtn;
    bIncele: TBitBtn;
    bSil: TBitBtn;
    bDuzelt: TBitBtn;
    bEkle: TBitBtn;
    Panel1: TPanel;
    Bevel1: TBevel;
    Bittarihl: TLabel;
    bastarihl: TLabel;
    bastarihk: TwwDBDateTimePicker;
    Bittarihk: TwwDBDateTimePicker;
    chkrevTar: TCheckBox;
    chkTestTarih: TCheckBox;
    Label1: TLabel;
    Label2: TLabel;
    Ttarihbit: TwwDBDateTimePicker;
    Ttarihbas: TwwDBDateTimePicker;
    Bevel2: TBevel;
    cxGrid2: TcxGrid;
    cxGridDBTableView1: TcxGridDBTableView;
    cxGridLevel1: TcxGridLevel;
    adoTemp: TADOQuery;
    adoListe: TADOQuery;
    DSListe: TDataSource;
    ActCariAnaPopUp: TActionList;
    acEkle: TAction;
    acDuzelt: TAction;
    acSil: TAction;
    acIncele: TAction;
    acListele: TAction;
    acKapat: TAction;
    cxGridDBTableView1URUN: TcxGridDBColumn;
    cxGridDBTableView1MARKA: TcxGridDBColumn;
    cxGridDBTableView1MODEL: TcxGridDBColumn;
    cxGridDBTableView1URETICIFIRMA: TcxGridDBColumn;
    cxGridDBTableView1ARIZAPROSEDURU: TcxGridDBColumn;
    cxGridDBTableView1DOKUMANNO: TcxGridDBColumn;
    cxGridDBTableView1REVIZYONNO: TcxGridDBColumn;
    cxGridDBTableView1REVIZYONTARIH: TcxGridDBColumn;
    cxGridDBTableView1TESTTARIH: TcxGridDBColumn;
    cxGridDBTableView1FORMNO: TcxGridDBColumn;
    PM: TPopupMenu;
    pmekle: TMenuItem;
    pmDuzelt: TMenuItem;
    pmSil: TMenuItem;
    pmIncele: TMenuItem;
    N1: TMenuItem;
    pmListele: TMenuItem;
    N2: TMenuItem;
    ptal1: TMenuItem;
    Onayla1: TMenuItem;
    procedure bKapatClick(Sender: TObject);
    procedure FormClose(Sender: TObject; var Action: TCloseAction);
    procedure FormKeyDown(Sender: TObject; var Key: Word;
      Shift: TShiftState);
    procedure acEkleExecute(Sender: TObject);
    procedure acDuzeltExecute(Sender: TObject);
    procedure acSilExecute(Sender: TObject);
    procedure acInceleExecute(Sender: TObject);
    procedure acListeleExecute(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  fmArgeNumuneFormuListe: TfmArgeNumuneFormuListe;

implementation

uses U_ArgeNumuneFormu, ana1,data,U_DBFunctions_;

{$R *.dfm}

procedure TfmArgeNumuneFormuListe.bKapatClick(Sender: TObject);
begin
    close;
end;

procedure TfmArgeNumuneFormuListe.FormClose(Sender: TObject;
  var Action: TCloseAction);
begin
  action:=CaFree;
  fmArgeNumuneFormuListe :=nil;
end;

procedure TfmArgeNumuneFormuListe.FormKeyDown(Sender: TObject;
  var Key: Word; Shift: TShiftState);
begin
if key=27 then close;
end;

procedure TfmArgeNumuneFormuListe.acEkleExecute(Sender: TObject);
begin
if not assigned(fmArgeNumuneFormu) then begin
  fmArgeNumuneFormu:=TfmArgeNumuneFormu.Create(self);
  fmArgeNumuneFormu.SMODE:='Y';
  fmArgeNumuneFormu.FormStyle:= fsnormal ;
  anaform.yetkiayarla(fmArgeNumuneFormu);
  YerAyarla(fmArgeNumuneFormu,false );
  fmArgeNumuneFormu.Showform;
  fmArgeNumuneFormu.ShowModal ;
end else begin
  fmArgeNumuneFormu.ShowModal;
end;
end;

procedure TfmArgeNumuneFormuListe.acDuzeltExecute(Sender: TObject);
begin
if KayitVarYok(Adoliste)=false then exit;

if not assigned(fmArgeNumuneFormu) then begin
  fmArgeNumuneFormu:=TfmArgeNumuneFormu.Create(self);
  fmArgeNumuneFormu.SMODE:='D';
  fmArgeNumuneFormu.BILISNO  := adoListe.FieldValues['BILISNO'];
  fmArgeNumuneFormu.FormStyle:= fsnormal ;
  anaform.yetkiayarla(fmArgeNumuneFormu);
  YerAyarla(fmArgeNumuneFormu,false );
  fmArgeNumuneFormu.Showform ;
  fmArgeNumuneFormu.ShowModal ;
end else begin
  fmArgeNumuneFormu.ShowModal;
end;
end;

procedure TfmArgeNumuneFormuListe.acSilExecute(Sender: TObject);
begin
if KayitVarYok(Adoliste)=false then exit;
end;

procedure TfmArgeNumuneFormuListe.acInceleExecute(Sender: TObject);
begin
if KayitVarYok(Adoliste)=false then exit;

if not assigned(fmArgeNumuneFormu) then begin
  fmArgeNumuneFormu:=TfmArgeNumuneFormu.Create(self);
  fmArgeNumuneFormu.SMODE:='I';
  fmArgeNumuneFormu.BILISNO  := adoListe.FieldValues['BILISNO'];
  fmArgeNumuneFormu.FormStyle:= fsnormal ;
  anaform.yetkiayarla(fmArgeNumuneFormu);
  YerAyarla(fmArgeNumuneFormu,false );
  fmArgeNumuneFormu.Showform ;
  fmArgeNumuneFormu.ShowModal ;
end else begin
  fmArgeNumuneFormu.ShowModal;
end;
end;

procedure TfmArgeNumuneFormuListe.acListeleExecute(Sender: TObject);
begin
  adoliste.Close;
  adoListe.SQL.Text:='select * from CS_ARGE_NUMUNE_FORMU where 1=1';

  if chkrevTar.Checked then begin
     adoListe.SQL.Add(' and REVIZYONTARIH between :t1 and :t2  ');
     adoListe.Parameters.ParamByName('t1').Value:=  bastarihk.Date;
     adoListe.Parameters.ParamByName('t1').Value:=  Bittarihk.Date;
  end;

  if chkTestTarih.Checked then begin
     adoListe.SQL.Add(' and TESTTARIH between :t3 and :t4 ');
     adoListe.Parameters.ParamByName('t3').Value:= Ttarihbas.Date;
     adoListe.Parameters.ParamByName('t4').Value:= Ttarihbit.Date;
  end;

  adoliste.open;
end;

end.
